import request from './base'
import glConfig from '../utils/config'
import store from '../store'
let api = "/api"
let wsApi = "/wsApi"
let msgApi = "/msgApi"
if(process.env.NODE_ENV == 'production'){
  api = wsApi = msgApi = ''
}
const requestApi = {
  
  //登录
 login(data) {
    return request({
      url: `${api}/quickoffice/api/work/login?code=${data.code}`,
      method: 'get',
      data:{}
    })
  },

  //获取签名
 jsSign(url) {
    return request({
      url: `${api}/quickoffice/api/work/jsSign?code=GDZCGL&url=${url}`,
      method: 'get'
    })
  },

  // 查询业务模块
 wfModuleTree(appid) {
  return request({
    url: `${wsApi}/quickoffice/api/wfModule/findTreeAll?appId=${appid}`,
    method: 'get',
    data:{}
  })
},

// 根据moduleCode查询业务详情
wfModuleByCode(appCode) {
return request({
  url: `${wsApi}/quickoffice/wfModule/findAppCode?appCode=${appCode}`,
  method: 'get',
  params:{}
})
},

  
  //获取用户公休情况
  official(data) {
    return request({
      url: `${api}/quickoffice/official`,
      method: 'get',
      data:{}
    })
  },
    
  //初始化公休
  InitOfficial(data) {
    return request({
      url: `${api}/quickoffice/official`,
      method: 'post',
      data
    })
  },
    
  //修改入职时间
  updateOfficial(data) {
    return request({
      url: `${api}/quickoffice/official`,
      method: 'put',
      data
    })
  },
  
  //查询审批节点
  getWfNode(data) {
    return request({
      url: `${api}/quickoffice/wfNode/findApproveList`,
      method: 'get',
      params:data
    })
  },
    
  //请假
  leave(data) {
    return request({
      url: `${api}/quickoffice/leave`,
      method: 'post',
      data
    })
  },

  
  //请假详情
  leaveInfo(id) {
    return request({
      url: `${api}/quickoffice/leave/${id}`,
      method: 'get',
      params:{}
    })
  },

  //生成电子单
  produceOrder(data) {
    return request({
      url: `${api}/quickoffice/leave/order/${data.recordId}`,
      method: 'post',
      data:{}
    })
  },

  //查看电子单据
  orderList(params) {
    return request({
      url: `${api}/quickoffice/leave/order`,
      method: 'get',
      params
    })
  },
     
  //审批详情
  approveInfo(id) {
    return request({
      url: `${api}/quickoffice/leave/approve/${id}`,
      method: 'get',
      params:{}
    })
  },

  //上传文件
  uploadFile(file) {
    console.log(89,glConfig.APPID)
    let formData = new FormData();
    formData.append("file",file);
    // formData.append("appId",glConfig.APPID);
    // formData.append("userId ",store.state.user.userInfo.userId);
    return request({
      url: `${wsApi}/quickoffice/api/userFile/add`,
      method: 'post',
      data:formData,
      headers:{
        'Content-Type':'multipart/form-data'
      }
    })
  },

  ///我的审批列表
  approveList(params) {
    return request({
      url: `${api}/quickoffice/leave/approve/list`,
      method: 'get',
      params
    })
  },

  ///我的申请列表
  leaveList(data) {
    return request({
      url: `${api}/quickoffice/leave`,
      method: 'get',
      params:data
    })
  },
  
  //请假
  revokeOrder(id) {
    return request({
      url: `${api}/quickoffice/leave/${id}`,
      method: 'delete',
      data:{}
    })
  },
  
  //审批
  approve(data) {
    return request({
      url: `${api}/quickoffice/wfRecord/approve`,
      method: 'put',
      data
    })
  },

  /*
    *会议管理
  */

  // 会议新增
 meetingAdd(data) {
  return request({
    url: `${wsApi}/quickoffice/meetingInfo/add`,
    method: 'post',
    data
  })
},
  
}

export default requestApi;



